import axios from "axios"
import store from "../store"

/**
 * 获取路由列表
 * @param token
 * @returns {Promise<unknown>}
 */
export const getRoutes = (token) => {
    return new Promise((resolve)=>{
        // 获取菜单列表
        axios.get('/menu/nav', {
            headers: {
                authorization: token
            }
        }).then(res=>{

            // 拿到menuList
            store.commit("setMenuList", res.data.data.nav)
            
            // 拿到用户权限
            store.commit("setPermList", res.data.data.authorities)

            resolve(res.data.data)
        })
    })
}